package com.itheima.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.itheima.excel.model.StudentModel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @version 1.0
 * @description 说明
 * @package com.itheima.excel
 */
@Getter
@Slf4j
public class StudentListener implements ReadListener<StudentModel> {

    private List<StudentModel> stuList;
    public StudentListener(List<StudentModel> stuList){
        this.stuList = stuList;
    }

    @Override
    public void invoke(StudentModel studentModel, AnalysisContext analysisContext) {
        stuList.add(studentModel);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        log.info("所有数据解析完成！");
    }
}
